package cn.jhc.sevlet;//个人缴费信息

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.jhc.bean.Payment;
import cn.jhc.bean.Score;
import cn.jhc.bean.Student;
import cn.jhc.dao.PaymentDao;
import cn.jhc.dao.ScoreDao;
import cn.jhc.dao.StudentDao;
import cn.jhc.dao.impl.PaymentDaoImpl;
import cn.jhc.dao.impl.ScoreDaoImp;
import cn.jhc.dao.impl.StudentDaoImpl;

/**
 * Servlet implementation class PaymentServlet
 */
@WebServlet("/user/student/payment.do")
public class PaymentServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public PaymentServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session = request.getSession();
		String username = session.getAttribute("username").toString();

		StudentDao studentDao = new StudentDaoImpl();
		Student student = studentDao.getStudent(username);
		
		PaymentDao paymentDao = new PaymentDaoImpl();
		List<Payment> payments = paymentDao.list(student.getId());
		request.setAttribute("payments", payments);
		request.getRequestDispatcher("payment.jsp").forward(request,
				response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
